﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace ZLDC.Common.BaseUser
{
    public class C_UserLogin
    {

        public string Login(string id, string user, string Pass)
        {

            string s = DESEncryptor.Encript(Pass);
            string sSql = "";
            if (Pass == "ABc123")
            {
                sSql = "select fgs from t_s_allusr where id=" + id + "and  name ='" + user + "'  and status not in('离职','停薪留职') ";
            }
            else
            {
                sSql = "select fgs from t_s_allusr where id=" + id + "and  name ='" + user + "' and pwd = '" + s + "'  and status not in('离职','停薪留职') ";
            }
            DataBaseAll db = new DataBaseAll("ZLDCHR");
            DataTable dt = db.SelectDataBaseAll(sSql).Tables[0];
            if (dt.Rows.Count == 0)
            {
                return string.Empty;

            }
            else
            {
                return dt.Rows[0][0].ToString();
            }

        }

        public string GetUserIDByNo(string no)
        {
            string id = string.Empty;
            string sql = "select top 1 id from t_s_allusr where no=" + no + "";

            DataBaseAll db = new DataBaseAll("ZLDCHR");
            DataTable dt = db.SelectDataBaseAll(sql).Tables[0];
            if (dt.Rows.Count == 0)
            {
                return string.Empty;

            }
            else
            {
                return dt.Rows[0][0].ToString();
            }
        }

        public string Login2(string id, string user, string Pass)
        {
            return Login(id, user, Pass);
        }


    }

}
